/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 *
 * @author PhanHongMinh
 */
public class TCPEchoClient {

    public static void main(String[] args) {
        try {
            Socket s = new Socket("localhost", 2014);
            InputStream is = s.getInputStream();
            OutputStream os = s.getOutputStream();
            for (int i = 0; i < 9; i++) {
                os.write(i);
                int ch= is.read();
                System.out.println(ch);
            }
            s.close();
        } catch (IOException e) {
             System.out.println("ERROR: " + e);
        }
    }
}
